package com.qf.mybatisplus.config.jwt;

import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author lehr
 */
@Slf4j
@Configuration
//@EnableWebSecurity
public class JwtInterceptorConfig extends WebSecurityConfigurerAdapter implements WebMvcConfigurer {



    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        log.info("加载auth-server");
        //默认拦截所有路径
        registry.addInterceptor(authenticationInterceptor())
                .addPathPatterns("/**")
                .excludePathPatterns("/favicon.ico","/token/getToken","/login/doLogin","/user/list","/test/test11","/login/getCode");

    }
    @Bean
    public JwtInterceptor authenticationInterceptor() {
        return new JwtInterceptor();
    }

    @Override
    protected void configure(HttpSecurity http) throws Exception {

    }
}